/* Y o u r   D e s c r i p t i o n                       */
/*                            AppBuilder Photon Code Lib */
/*                                         Version 0.83B */

/* Standard headers */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

/* Toolkit headers */
#include <Ph.h>
#include <Pt.h>
#include <Ap.h>

/* Local headers */
#include "abimport.h"
#include "proto.h"

extern unsigned long up_rate;
extern short tcount;
extern short sample_size;
extern short *buff;

int
scroll_move( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
PtArg_t	   args[1];
char       str[40];
//int      old_count = ((PtTrendWidget_t *)ABW_trend_demo)->trend_count;
PtScrollbarCallback_t *scroll = cbinfo->cbdata;

	/* eliminate 'unreferenced' warnings */
	apinfo = apinfo;

	if (ApName(widget) == ABN_rate_sb) 
	{
		sample_size = scroll->position;
		if(buff) free(buff);
		buff = calloc(1,tcount * sample_size * sizeof(short));
	}	
	if (ApName(widget) == ABN_scan_sb) 
	{
     PtSetArg(&args[0],Pt_ARG_TIMER_REPEAT,scroll->position,0);
     PtSetResources(ABW_timer1, 1, &args[0]);
	}
	if (ApName(widget) == ABN_scan_timer) 
	{
	 *str=0;
	 sprintf(str,"%dms",scroll->position);	
     PtSetArg(&args[0],Pt_ARG_TIMER_REPEAT,scroll->position,0);
     PtSetResources(ABW_timer2, 1, &args[0]);
     PtSetArg(&args[0],Pt_ARG_TEXT_STRING,str,strlen(str)+1);
     PtSetResources(ABW_PtTextTimer2, 1, &args[0]);
	}
			
	return(Pt_CONTINUE);
}

